package com.controller;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.entity.Hr;
import com.mapper.HrMapper;
import com.service.HrService;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author viyoung
 * @since 2019-10-24
 */
@Controller
@RequestMapping("/hr")
public class HrController {

	@Autowired
	public HrService hrService;

	@Autowired
	public HrMapper hrMapper;

	@RequestMapping("/list")
	@ResponseBody
	public List<Hr> list() {
		return hrService.list();

	}

	@RequestMapping("/listmapper")
	@ResponseBody
	public List<Hr> listmappper() {
		return hrMapper.selectList(null);
	}

	/**
	 * Mybatis-Plus自带的分页插件
	 * 分页
	 * @param request
	 * @return
	 */
	@RequestMapping("/page")
	@ResponseBody
	public IPage<Hr> page(HttpServletRequest request) {
		long current = 0;// 几页
		long size = 0;// 多少条

		String currents = request.getParameter("current");
		String sizes = request.getParameter("size");

		if (currents == null && sizes == null) {
			current = 1;// 几页
			size = 2;// 多少条
		} else {
			current = Long.valueOf(currents);
			size = Long.valueOf(sizes);
		}

		Page<Hr> hrPage = new Page<>(current, size);

		return hrService.page(hrPage);

	}

	/**
	 * 使用条件构造器 构造查询条件 查询
	 */
	@RequestMapping("/findByRemake")
	@ResponseBody
	public List<Hr> findByRemake(HttpServletRequest request) {
		String remake = request.getParameter("remake");

		System.out.println("---------" + remake);

		return hrService.findByRemake(remake);
	}
	
	/**
	 * 莫名其妙的git!!!!!!!!!!!!!
	 */
	public void  testGit(){

		String  sss="";

		String  ss2s="真的搞不懂这git。。。。";

	}
	
	
	public void test2(){
		
		
		
	}

}
